#!/usr/bin/env python
# coding=utf-8
import pretty_errors

from urllib.request import urlopen
from bs4 import BeautifulSoup

html = urlopen("http://www.pythonscraping.com/pages/warandpeace.html")
bsobj = BeautifulSoup(html, 'lxml')
namelist = bsobj.find_all("span", {"class": "green"})
for name in namelist:
    print(name.get_text())  # get_text方法,清除所有标签,只留下文本内容
